{php}

$epayinfo = get_addon_info('epay');

{/php}
{if (!$epayinfo || !$epayinfo['state'])}
<div class="alert alert-danger-light ">
    <p><i class="fa fa-info"></i> {:__('开通合同支付需要安装“微信支付宝”插件')}</p>
</div>
{/if}
<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <div class="panel-lead"><em>合同在线支付、续费</em></div>
        {:build_heading(null,FALSE)}
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
                        <input id="c-key" type="hidden" data-rule="required"  class="form-control" name="row[key]" value="{$key}" readonly/>
                        <div class="row">

                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-wechat_id" class="control-label col-xs-12 col-sm-2">{:__('微信支付关联收款账户')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    {:build_select("row[values][weixin_id]", $account_list,isset($row['values']['weixin_id'])?$row['values']['weixin_id']:1, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-alipay_id" class="control-label col-xs-12 col-sm-2">{:__('支付宝关联收款账户')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    {:build_select("row[values][alipay_id]", $account_list,isset($row['values']['alipay_id'])?$row['values']['alipay_id']:1, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}

                                </div>
                            </div>

                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-online_pay" class="control-label col-xs-12 col-sm-2">{:__('启用在线收款')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    {:build_radios('row[values][online_pay]', ['1'=>__('开启'), '0'=>__('关闭')], isset($row['values']['online_pay'])?$row['values']['online_pay']:0)}

                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_pay" class="control-label col-xs-12 col-sm-2">{:__('启用续费合同')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    {:build_radios('row[values][renew_pay]', ['1'=>__('开启'), '0'=>__('关闭')], isset($row['values']['renew_pay'])?$row['values']['renew_pay']:0)}

                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_pay" class="control-label col-xs-12 col-sm-2">{:__('续费日期处理方式')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    {:build_radios('row[values][renew_type]', ['1'=>__('合同结束时间累加'), '0'=>__('支付成功时间累加')], isset($row['values']['renew_type'])?$row['values']['renew_type']:0)}
                                    <span class="help-block">*合同过期一段时间了，是按照过期时间续期还是，当前支付成功时间续期。</span>
                                </div>
                            </div>

                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_day" class="control-label col-xs-12 col-sm-2">{:__('可提前续费天数')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <input id="c-renew_day" class="form-control" name="row[values][renew_day]"  type="number" value="{:isset($row['values']['renew_day'])?$row['values']['renew_day']:30}">
                                    <span class="help-block">*合同过期前多少天才能续费。</span>
                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_max" class="control-label col-xs-12 col-sm-2">{:__('最多可续费数量')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <input id="c-renew_max" class="form-control" name="row[values][renew_max]"  type="number" value="{:isset($row['values']['renew_max'])?$row['values']['renew_max']:1}">
                                    <span class="help-block">可理解为续费的时候最多下单数量</span>
                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_day" class="control-label col-xs-12 col-sm-2">{:__('续费单位')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <select class=" form-control" name="row[values][renew_unit]" >

                                        <option value="year" {if isset($row["values"]['renew_unit'])&&$row["values"]['renew_unit']=='year'} selected {/if}>年</option>
                                        <option value="month" {if isset($row["values"]['renew_unit'])&&$row["values"]['renew_unit']=='month'} selected {/if}>月</option>
                                        <option value="day" {if isset($row["values"]['renew_unit'])&&$row["values"]['renew_unit']=='day'} selected {/if}>日</option>

                                    </select>
                                </div>
                            </div>

                            <div class="col-md-12 col-xs-12 form-group">
                                <label for="c-renew_percentage" class="control-label col-xs-12 col-sm-2">{:__('续费价格')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <input id="c-renew_percentage" class="form-control" name="row[values][renew_percentage]"  type="number" value="{:isset($row['values']['renew_percentage'])?$row['values']['renew_percentage']:100}">
                                    <span class="help-block">合同的总额百分比,合同可单独设价格</span>
                                </div>
                            </div>



                            <div class="form-group col-md-12 col-xs-12">
                                <label for="c-agreement" class="control-label col-xs-12 col-sm-2">{:__('收款协议')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <textarea id="c-agreement" data-rule="required" class="form-control editor " name="row[values][agreement]" rows="5">{:isset($row['values']['agreement'])?$row['values']['agreement']:''}</textarea>
                                    <span class="help-block">*支持插入回款单字段，如回款单号{literal}{:number}{/literal}。</span>
                                </div>
                            </div>


                            <div class="form-group col-md-12 col-xs-12">
                                <label for="c-r_agreement" class="control-label col-xs-12 col-sm-2">{:__('合同续费协议')}:</label>
                                <div class="col-xs-12 col-sm-8">
                                    <textarea id="c-r_agreement" data-rule="required" class="form-control editor " name="row[values][r_agreement]" rows="5">{:isset($row['values']['r_agreement'])?$row['values']['r_agreement']:''}</textarea>
                                    <span class="help-block">*支持插入合同字段，如合同单号{literal}{:number}{/literal}。</span>
                                </div>
                            </div>

                            <div class="form-group layer-footer">
                                <label class="control-label col-xs-12 col-sm-2"></label>
                                <div class="col-xs-12 col-sm-8">
                                    <button type="submit" class="btn btn-success btn-embossed disabled">{:__('submit')}</button>
                                    <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
                                </div>
                            </div>
                    </form>



                </div>
            </div>

        </div>
    </div>
</div>

<script>
    require.callback = function () {

        define('backend/facrm/setting/payonline', ['jquery', 'form'], function ($, Form) {
            var Controller = {
                index: function () {
                    Form.api.bindevent($("form[role=form]"));

                }
            };
            return Controller;
        });
    }
</script>




